package wfb.frontend.threads;

import wfb.definitions.WfbDbException;
import wfb.definitions.WfbDbInterface;
import wfb.definitions.threadInterfaces.UpdateInterface;

import javax.swing.*;

/**
 * @author Tobias Peitzsch
 */
public class UpdateThread implements UpdateInterface {
	private String com=null;
	private String country=null;
	private WfbDbInterface wdi=null;
	/* (non-Javadoc)
	 * @see wfb.definitions.ThreadInterfaces.UpdateInterface#setComment(java.lang.String)
	 */
	public void setComment(String com) {
		this.com=com;
	}
	/* (non-Javadoc)
	 * @see wfb.definitions.ThreadInterfaces.UpdateInterface#setCountry(java.lang.String)
	 */
	public void setCountry(String country) {
		this.country=country;
	}
	/* (non-Javadoc)
	 * @see wfb.definitions.ThreadInterfaces.UpdateInterface#setWfbDbImpl(wfb.definitions.WfbDbInterface)
	 */
	public void setWfbDbImpl(WfbDbInterface wdi) {
		this.wdi=wdi;
	}
	/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		if(com==null||country ==null||wdi==null)return;
		try{
			wdi.updateCountryComment(country,com);
		}
		catch(WfbDbException e){
			JOptionPane.showMessageDialog(null,"Das Update des Kommentar ist fehlgeschlagen!\n" 
				+ e.getMessage(),"Fehler",JOptionPane.ERROR_MESSAGE);
		}
	}
}